<?php
class ClsNaanalJS
{
    private function __construct()
    {
    }
    private static function executeFile($naanal_module_js_file)
    {
        $arrAllowedToken=array 
        (
            T_OPEN_TAG,
            T_STRING,//html code
            T_ECHO,//echo
            T_CONSTANT_ENCAPSED_STRING,
            T_CLOSE_TAG,//?'>
            T_WHITESPACE,//' '
            T_INLINE_HTML
        );
        $content=  file_get_contents($naanal_module_js_file);
        $arrToken=token_get_all($content);
        foreach($arrToken as $ind=>$data)
        {
            $isAllowed=false;
            $isFunctionError=false;
            if(!isset($data[2]) ||  in_array($data[0], $arrAllowedToken))
            {
                $isAllowed=true;
            }
            else
            {
                $isAllowed=false;
            }
            if($isAllowed===false)
            {
                $elementType=  token_name($data[0]);
                trace("File: {$tplPath}, Page: {$template}, Line No.: {$data[2]}, Element Type : {$elementType} Element '{$data[1]}' not allowed inside javascript PHP file. ");
            }
        }
        ob_start();
        include $naanal_module_js_file;
        return ob_get_clean();
    }
    public static function renderModuleJS($module)
    {
        if(file_exists(NAANAL_APP_PATH."/module_js/{$module}.php"))
        {
            return self::executeFile(NAANAL_APP_PATH."/module_js/{$module}.php");
        }
    }
}
?>